领域人工智能机器学习标记数据本页总览标记数据 标记编码步骤 倒入有用的软件包 import numpy as npfrom sklearn import preprocessing 定义样本标签 # Sample input labelsinput_labels = ['red','black','red','green','black','yellow','white'] 创建和训练标签编码器对象 # Creating the label encoderencoder = preprocessing.LabelEncoder()encoder.fit(input_labels) 通过编码随机排序列表来检查性能